"""
This module contains some utilities that will be required by other modules.
"""
from constants import mud
import re

def isValidUser(name):
    if not name.isalpha():
        return False

    if not len(name) >= mud.minname or not len(name) <= mud.maxname:
        return False

    return True

def isValidPassword(password):
    if not len(password) >= mud.minpass and not len(password) <= mud.maxpass:
        return False

    return True

def passwordStrength(password):
    """
    Evaluates the password and returns a string representation of the strength:
    [==--------)(20%)
    """
    score = 20
    if len(password) < 10:
        score -= 20
    if re.search('\d+', password):
        score += 20
    if re.search("[a-z]", password) and re.search("['A-Z]", password):
        score += 20
    if re.search("[!@#$%^&*()-.", password):
        score += 20

    perc = score/10
    bar = "["
    for r in range(0, perc):
        bar += "="
    for r in range(0, 10-perc):
        bar += "-"
    bar += "]"
    return "Password strength: %s(%d%%)" %(bar, perc)

def argify(line):
    line = line.strip()
    if not len(line):
        return

    